package com.hs.server.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hs.server.domain.VehZnshzlzpxx;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface VehZnshzlzpxxMapper extends BaseMapper<VehZnshzlzpxx> {
    @Select("SELECT shzt2 FROM veh_znshzlzpxx WHERE lsh = #{lsh}")
    List<String> getShztsByLsh(String lsh);
    @Select("SELECT shzt FROM veh_znshzlzpxx WHERE lsh = #{lsh} and zpzl not in (${zpzls})")
    List<String> getShztsByLshWithoutLinked(@Param("lsh")String lsh, @Param("zpzls")String zpzls);

    @Select("SELECT count(*) FROM veh_znshzlzpxx WHERE LENGTH(trim(jyx))>0 AND lsh = #{lsh}")
    int getNeedCount(String lsh);
    @Select("SELECT count(*) FROM veh_znshzlzpxx WHERE LENGTH(trim(jyx))>0 AND shzt!=0 AND lsh = #{lsh}")
    int getAlreadyByLsh(String lsh);//可能加多一个条件 LENGTH(trim(jyx))>0

    @Select("SELECT zpzl FROM veh_znshzlzpxx WHERE lsh = #{lsh} and zpzl not in (${zpzls}) and shzt='5'")
    List<String> getBtgZpzl(@Param("lsh")String lsh, @Param("zpzls")String zpzls);

    @Select("SELECT zpzl FROM veh_znshzlzpxx WHERE lsh = #{lsh} and shzt2='5'")
    List<String> getBtgZpzls(@Param("lsh")String lsh);

    @Update("update veh_znshzlzpxx set shzt2 = #{shzt},shbtgyy2 = #{shbtgyy} WHERE lsh = #{lsh} and zpzl = #{zpzl}")
    int updateLinkedShzt(String lsh, String shzt,String shbtgyy,String zpzl);

    @Select({
            "<script>",
            "SELECT * FROM veh_znshzlzpxx",
            "WHERE lsh = #{lsh}",
            "<if test='zpzls != null and zpzls.size > 0'>",
            "AND zpzl IN",
            "<foreach collection='zpzls' item='item' open='(' separator=',' close=')'>",
            "#{item}",
            "</foreach>",
            "</if>",
            "</script>"
    })
    List<VehZnshzlzpxx> getVehZnshzlzpxxList(String lsh,List<String> zpzls);
}
